from django import forms
from django.contrib.auth.models import User
from timesheet.models import Activity
from timesheet.models import Project
from timesheet.models import Time


class UsersForm(forms.Form):
    users = forms.ModelChoiceField(queryset=User.objects.all())


class ActivityForm(forms.Form):
    activities = forms.ModelChoiceField(widget=forms.Select(attrs={'id': 'activities'}),
                                                           queryset=Activity.objects.all())


class ProjectsForm(forms.Form):
    def __init__(self, projects, *args, **kwargs):
        super(ProjectsForm, self).__init__(*args, **kwargs)
        self.fields['projects'] = forms.ModelChoiceField(widget=forms.Select(attrs={'id': 'projects'}),
                                                         queryset=projects)


class UserMediaForm(forms.Form):
    class Media:
        css = {
            'all': ('css/user/style.css',)
            }


class CompletionMediaForm(forms.Form):
    class Media:
        css = {
            'all': ('css/completion/style.css',)
            }


class DateForm(forms.Form): 
    date = forms.DateField(widget=forms.TextInput(attrs={'size':'10', 'onFocus':'this.select();lcs(this)',
                                                                        'onClick':'event.cancelBubble=true;this.select();lcs(this)'}))
    class Media:
        js = ('js/calendar.js',)


class DateIntervalForm(forms.Form): 
    initial_date = forms.DateField(widget=forms.TextInput(attrs={'size':'10', 'onFocus':'this.select();lcs(this)',
                                                                        'onClick':'event.cancelBubble=true;this.select();lcs(this)'}))
    end_date = forms.DateField(widget=forms.TextInput(attrs={'size':'10', 'onFocus':'this.select();lcs(this)',
                                                                        'onClick':'event.cancelBubble=true;this.select();lcs(this)'}))

    class Media:
        js = ('js/calendar.js',)


class TimeForm(forms.Form):
    time = forms.FloatField(widget=forms.TextInput(attrs={'size':'3', 'id': 'hours'}))
    details = forms.CharField(widget=forms.TextInput(attrs={'size':'70', 'id': 'details'}), required=False)    
